<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title><tiles:getAsString name="pageTitle"/></title>
    <sec:csrfMetaTags />
    <link rel="stylesheet" href="<s:url value="/webjars/bootstrap/dist/css/bootstrap.min.css"/>">
    <link rel="stylesheet" href="<s:url value="/webjars/font-awesome/css/font-awesome.min.css"/>">
    <link rel="stylesheet" href="<s:url value="/dist/css/AdminLTE.min.css"/>">
    <link rel="stylesheet" href="<s:url value="/dist/css/skins/_all-skins.min.css"/>">
    <link rel="stylesheet" href="<s:url value="/webjars/jquery-ui/jquery-ui.min.css"/>">
    <link rel="stylesheet" href="<s:url value="/webjars/datatables/media/css/dataTables.bootstrap.css"/>">

    <link rel="stylesheet" href="<s:url value="/webjars/datatables.net-select-bs/css/select.bootstrap.css"/>">
    <link rel="stylesheet" href="<s:url value="/webjars/bootstrap3-dialog/dist/css/bootstrap-dialog.min.css"/>">
    <link rel="stylesheet" href="<s:url value="/webjars/select2/dist/css/select2.min.css"/>">
    


    <script src="<s:url value="/webjars/jquery/dist/jquery.min.js"/>"></script>
    
    <link rel="stylesheet" href="<s:url value="/css/fileinput.min.css"/>">
    <script type="text/javascript" src="<s:url value="/js/fileinput.min.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/js/locales/zh.js"/>"></script>
    
    <script type="text/javascript" src="<s:url value="/webjars/jquery-ui/jquery-ui.min.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/webjars/bootstrap/dist/js/bootstrap.min.js"/>"></script>

    <script type="text/javascript" src="<s:url value="/webjars/datatables/media/js/jquery.dataTables.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/webjars/datatables/media/js/dataTables.bootstrap.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/webjars/datatables.net-select/js/dataTables.select.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/webjars/bootstrap3-dialog/dist/js/bootstrap-dialog.min.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/webjars/select2/dist/js/select2.full.min.js"/>"></script>


    <script type="text/javascript"
            src="<s:url value="/components/jquery-slimscroll/jquery.slimscroll.min.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/components/fastclick/lib/fastclick.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/dist/js/adminlte	.js"/>"></script>
    <script type="text/javascript">
        $(document).ready(function () {
        	var token = $("meta[name='_csrf']").attr('content');
			var header = $("meta[name='_csrf_header']").attr('content');
			$(document).ajaxSend(function(e,xhr,options){
				xhr.setRequestHeader(header,token);
			});
			
            var pathname = window.location.pathname;
            var entity = $("a[href='" + pathname + "']");
            entity.parent().addClass("active");
            entity.parent().parent().parent().addClass("active menu-open");

            $(".submitForm").submit(function(){
                $.ajax({
					url:$(this).attr('action'),
					type:'POST',
					data:$(this).serialize(),
					success:function(result){
						if(result.status == 200){
							BootstrapDialog.alert(result.message);
							windows.location.href = '<s:url value="/"/>'+ result.location; 
						}else{
							BootstrapDialog.show({
								title:'出现错误',
								message:result.message,
								type:BootstrapDialog.TYPE_DANGER,
								buttons:[{
									label:'Close',
									action:function(dialogItself){
										dialogItself.close();
									}
								}]
							});
						}
					}
                });
				return false;
            });

            $("a[data-toggle='dialog']").click(function(){
				BootstrapDialog.show({
					message:$("<div></div>").load($(this).data("url"))
				})
            });

            $(".basicSelect2").select2();

           	$("a[data-toggle='doAjax']").click(function(){
               	var msg = $(this).data('msg');
               	var targetUrl = $(this).attr("href");
               	BootstrapDialog.show({
					message:msg,
					buttons:[{
						label:'Button 1',
						action:function(dialogItself){
							$.ajax({
								url:targetUrl,
								type:"POST",
								success:function(result){
									dialogItself.close();
									if(result.status == 200){
										BootstrapDialog.alert(result.message);
										setTimeout(function() {
											window.location.reload(false);
										}, 3000)
									}else{
										BootstrapDialog.alert(result.message)
									}
								}
							})
						}
					},{
						label:'Button 1',
						action:function(dialogItself){
							dialogItself.close();
						}
					}]
                });
				return false;
            });
        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <tiles:insertAttribute name="pageTop"/>
    <tiles:insertAttribute name="pageLeft"/>

    <!-- Content Wrapper. Cotains page content -->
    <div class="content-wrapper">

        <tiles:insertAttribute name="pageContent"/>
    </div>

    <!--  -->
    <footer class="main-footer">
        <div class="pull-right hidden-xs">
            <b>Version</b> 2.4.0
        </div>
        <strong>
            Copyright &cpoy; 2014-2016<a href="">dsadsa</a>
        </strong>
    </footer>
</div>

</body>
</html>